1 /*
2  * Copyright (c) 2013 - Mauro Carvalho Chehab <m.chehab@samsung.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation version 2.1 of the License.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
17  *
18  * Described on IEC/CENELEC DS/EN 62216-1:2011
19  *
20  * I couldn't find the original version, so I used what's there at:
21  *	http://tdt.telecom.pt/recursos/apresentacoes/Signalling Specifications for DTT deployment in Portugal.pdf
22  */
23 
24 /**
25  * @file desc_logical_channel.h
26  * @ingroup descriptors
27  * @brief Provides the descriptors for the LCN - Logican Channel Number
28  * @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
29  * @author Mauro Carvalho Chehab
30  *
31  * @par Relevant specs
32  * The descriptor described herein is defined at:
33  * - IEC/CENELEC DS/EN 62216-1:2011
34  *
35  * @see http://tdt.telecom.pt/recursos/apresentacoes/Signalling Specifications for DTT deployment in Portugal.pdf
36  *
37  * @par Bug Report
38  * Please submit bug reports and patches to linux-media@vger.kernel.org
39  */
40 
41 module libdvbv5_d.desc_logical_channel;
42 
43 import libdvbv5_d.descriptors: dvb_desc;
44 import libdvbv5_d.dvb_fe: dvb_v5_fe_parms;
45 
46 extern (C):
47 
48 /**
49  * @struct dvb_desc_logical_channel_number
50  * @ingroup descriptors
51  * @brief Structure containing the logical channel number entires
52  *
53  * @param service_id			service id
54  * @param visible_service_flag		visible service flag
55  * @param logical_channel_number	logical channel number
56  */
57 
58 struct dvb_desc_logical_channel_number
59 {
60     align (1):
61 
62     ushort service_id;
63 
64     union
65     {
66         align (1):
67 
68         ushort bitfield;
69 
70         struct
71         {
72             import std.bitmanip : bitfields;
73             align (1):
74 
75             mixin(bitfields!(
76                 ushort, "logical_channel_number", 10,
77                 ushort, "reserved", 5,
78                 ushort, "visible_service_flag", 1));
79         }
80     }
81 }
82 
83 /**
84  * @struct dvb_desc_logical_channel
85  * @ingroup descriptors
86  * @brief Structure containing the logical channel number descriptor
87  *
88  * @param type		descriptor tag
89  * @param length	descriptor length
90  * @param next		pointer to struct dvb_desc
91  * @param lcn		pointer to struct dvb_desc_logical_channel_number
92  */
93 struct dvb_desc_logical_channel
94 {
95     align (1):
96 
97     ubyte type;
98     ubyte length;
99     dvb_desc* next;
100 
101     dvb_desc_logical_channel_number* lcn;
102 }
103 
104 // struct dvb_v5_fe_parms;
105 
106 /**
107  * @brief Initializes and parses the logical channel number descriptor
108  * @ingroup descriptors
109  *
110  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
111  * @param buf	buffer containing the descriptor's raw data
112  * @param desc	pointer to struct dvb_desc to be allocated and filled
113  *
114  * This function allocates a the descriptor and fills the fields inside
115  * the struct. It also makes sure that all fields will follow the CPU
116  * endianness. Due to that, the content of the buffer may change.
117  *
118  * @return On success, it returns the size of the allocated struct.
119  *	   A negative value indicates an error.
120  */
121 int dvb_desc_logical_channel_init (
122     dvb_v5_fe_parms* parms,
123     const(ubyte)* buf,
124     dvb_desc* desc);
125 
126 /**
127  * @brief Prints the content of the logical channel number descriptor
128  * @ingroup descriptors
129  *
130  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
131  * @param desc	pointer to struct dvb_desc
132  */
133 void dvb_desc_logical_channel_print (
134     dvb_v5_fe_parms* parms,
135     const(dvb_desc)* desc);
136 
137 /**
138  * @brief Frees all data allocated by the logical channel number descriptor
139  * @ingroup descriptors
140  *
141  * @param desc pointer to struct dvb_desc to be freed
142  */
143 void dvb_desc_logical_channel_free (dvb_desc* desc);